package com.android.Translator.View.MyAdapter;

import java.util.ArrayList;

import android.app.Activity;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.android.Translator.R;

public class ListExampleAdapter extends ArrayAdapter<String>{
	private final Activity context;
	private final ArrayList<String> Text;
	public ListExampleAdapter(Activity context,
	ArrayList<String> Text) {
	super(context, R.layout.item_list_example, Text);
	this.context = context;
	this.Text = Text;
	}
	@Override
	public View getView(int position, View view, ViewGroup parent) {
		
		//lay screen size
		DisplayMetrics displaymetrics = new DisplayMetrics();
		context.getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
		
		int height = displaymetrics.heightPixels;
		int width = displaymetrics.widthPixels;
		
		LayoutInflater inflater = context.getLayoutInflater();
		View rowView= inflater.inflate(R.layout.item_list_example, null, true);
		TextView txtEx1 = (TextView) rowView.findViewById(R.id.txtEx1);
		txtEx1.setWidth(width/2);
		TextView txtEx2 = (TextView) rowView.findViewById(R.id.txtEx2);
		txtEx2.setWidth(width/2);

		
		if (position < Text.size()/2)
		{
			txtEx1.setText(Text.get(position*2));
			txtEx2.setText(Text.get(position*2+1));
		}
	
		return rowView;
	}
}